<?php
namespace DBConnection;

class DBConnection
{
	private static $singleton;
	private $connection;
	
	private function __construct()
	{
		$dsn = 'mysql:host=localhost;dbname=allall';
		$username = 'root';
		$passwd = 'root';
		//$options
		$this->connection = new \PDO($dsn, $username, $passwd);
// 		$this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
		echo "<p>DB Connection established ... </p>";
	}
	
	private function __clone(){}
	
	public static function getSingleton()
	{
		if(empty(self::$singleton))
		{
			self::$singleton = new DBConnection();
		}
		return self::$singleton;
	}
	
	public function getConnection()
	{
		return $this->connection;
	}
	
	public static function getDBConnection()
	{
		return self::getSingleton()->getConnection();
	}
}